
cmake_minimum_required(VERSION 3.5.1)

project(flatpak-manager LANGUAGES CXX VERSION 0.0.1)

include(cmake/SparkEnvConfig.cmake)
include(cmake/SparkMacrosConfig.cmake)
include(cmake/SparkFindLibraries.cmake)
include(cmake/SparkFindQt5Config.cmake)
# include(cmake/SparkFindQt6Config.cmake)
include(cmake/SparkMacrosExtendConfig.cmake)

# 资源文件路径
set(QRC_SOURCES "sources.qrc")

# add_subdirectory(widgets/FlatpakManager)
# add_subdirectory(widgets/FlatpakRepoWidget)

spark_add_library_realpaths(
    # widgets/FlatpakManager/FlatpakUtil start
    src/widgets/FlatpakManager/FlatpakUtil/FlatpakCommand
    src/widgets/FlatpakManager/FlatpakUtil/FlatpakBase+FlatpakCommand
    
    src/widgets/FlatpakManager/FlatpakUtil/AccessManage
    src/widgets/FlatpakManager/FlatpakUtil/AppcationManager
    src/widgets/FlatpakManager/FlatpakUtil/ApplicationBuildManage
    src/widgets/FlatpakManager/FlatpakUtil/InstalledManager
    src/widgets/FlatpakManager/FlatpakUtil/PermissionManage
    src/widgets/FlatpakManager/FlatpakUtil/RemoteSearch
    src/widgets/FlatpakManager/FlatpakUtil/RepoManage+FlatpakBase
    src/widgets/FlatpakManager/FlatpakUtil+AccessManage+AppcationManager+ApplicationBuildManage+FlatpakCommand+InstalledManager+PermissionManage+RemoteSearch+RepoManage
    # widgets/FlatpakManager/FlatpakUtil  end 


    # widgets/FlatpakRepoWidget start
    src/widgets/FlatpakRepoWidget/NetworkIcon
    src/widgets/FlatpakRepoWidget+NetworkIcon

    # widgets/FlatpakManager  start
    src/widgets/FlatpakManager+FlatpakUtil+FlatpakRepoWidget
    # widgets/FlatpakManager  end
)

spark_add_executable_path(${PROJECT_NAME} src
    ${QRC_SOURCES}
)
target_link_qt5(${PROJECT_NAME})
target_link_FlatpakManager(${PROJECT_NAME})

# tests
option(ENABLE_TESTS "启用测试代码的编译" OFF)
if(ENABLE_TESTS)
    # 一行一可执行目标形式 
    spark_add_executable_realpaths(
        remotelist:tests/remotelist+FlatpakUtil
        packageinfo:tests/packageinfo+FlatpakUtil
        testlist:tests/testlist+FlatpakUtil
        testinfo:tests/testinfo+FlatpakUtil
    )
endif(ENABLE_TESTS)


include(cmake/SparkDesktopMacros.cmake)
# 内容默认应用名称: Name= 应与项目名称相同
spark_desktop_macros(
    # 应用名称: Name=
    ${PROJECT_NAME}
    # 应用名称: Name[zh_CN]=
    "Flatpak 图形化管理器"
    # 应用说明: Comment=
    "一个简单的 Flatpak 图形化管理器"
    # 应用类型: Type=
    "Application"
    # 执行程序: Exec=
    "/usr/bin/${PROJECT_NAME} %F"
    # 图标路径: Icon=
    "x"
    # 应用分类: Category=
    "Utility"
    # MIME类型: MimeType=
    "application/vnd.flatpak.repo"
)
install(FILES ${SPARK_DESKTOP_FILE}
    DESTINATION /usr/share/applications
)

# install, 
install(TARGETS ${PROJECT_NAME}
    DESTINATION /usr/bin)

include(cmake/SparkBuildGraphviz.cmake)

# 注释行(使用方式)
find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR})
add_package_descript(cmake/package-deb.descript)